export function useTable() {
    const gridOptions = reactive<any>({
        border: true,
        columnConfig: {
            resizable: true,
        },
        columns: [
            { field: 'id', title: '角色id' },
            { field: 'display_name', title: '角色名称' },
            { field: 'description', title: '描述' },
            { field: 'privileges', title: '权限' },
            { slots: { default: 'operate' }, title: '操作', width: 300 },
        ],
        data: [],
        editConfig: {
            mode: 'row',
            showStatus: true,
            trigger: 'manual',
        },
        height: 530,
        keepSource: true,
        loading: false,
        pagerConfig: {
            currentPage: 1,
            enabled: true,
            pageSize: 10,
            pageSizes: [10, 20, 50, 100, 200, 500],
            total: 0,
        },
        showOverflow: true,
    })

    const btns: any = [
        {
            label: '分配权限',
            type: 'primary',
            value: 'patch',
        },
        {
            label: '编辑',
            value: 'edit',
        },
        {
            label: '删除',
            value: 'delete',
        },
    ]

    const formatTag = (row: any) => {
        if (row?.memberTagList && row?.memberTagList?.length)
            return row?.memberTagList

        return []
    }
    return { btns, formatTag, gridOptions }
}
